//
//  ViewController.m
//  UISearchViewController
//
//  Created by LINAICAI on 2017/1/12.
//  Copyright © 2017年 LINAICAI. All rights reserved.
//

#import "ViewController.h"
#import "LBCityPickerViewController.h"
#import "LBCityButton.h"
#import "LBNavigationController.h"
#import <MJExtension.h>
#import "LBLocationManager.h"
@interface ViewController ()
@end

@implementation ViewController
- (UIStatusBarStyle)preferredStatusBarStyle NS_AVAILABLE_IOS(7_0){
    return UIStatusBarStyleLightContent;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    __block LBCityButton *button = [[LBCityButton alloc]initWithTitle:@"全国" click:^(NSString *cityName) {
        LBNavigationController *nav = [[LBNavigationController alloc]initWithRootViewController:LBCityPickerViewController.defaultViewController];
        
        [LBCityPickerViewController showWithTitle:@"选择城市" fromVc:self toVc:nav complete:^(LBCityModel *city){
            NSLog(@"选中城市名:%@ 选中城市code=%@",city.areaName,city.areaCode);
            [button updateCityName:city.areaName];
            
        }];
    }];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
    // Do any additional setup after loading the view.
    
    //获取定位城市
    [[LBLocationManager shared]getCurrentLocationWith:^(NSString * _Nonnull cityName) {
        NSLog(@"cityName=%@",cityName);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
